package com.futureCloudMOM.core.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.futureCloudMOM.common.constant.GenConstants;
import com.futureCloudMOM.core.entity.FBaseEntity;
import com.futureCloudMOM.framework.dict.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Produce_TaskBillSub", description = "生产订单子表")
@TableName(value = "Produce_TaskBillSub")
public class ProduceTaskBillSub extends FBaseEntity implements Serializable {


    @ApiModelProperty("组织ID")
    @TableField(value = "departmentId")
    private Long departmentId;

    @NotNull(message="[任务ID]不能为空")
    @ApiModelProperty("任务ID")
    @TableField(value = "taskBillId")
    private Long taskBillId;

    @NotNull(message="[工序ID]不能为空")
    @ApiModelProperty("工序ID")
    @TableField(value = "procId")
    private Long procId;

    @NotNull(message="[序号]不能为空")
    @ApiModelProperty("序号")
    @TableField(value = "subNo")
    private Long subNo;

    @ApiModelProperty("是否派工")
    @TableField(value = "assignStatus")
    private Long assignStatus;

    @NotNull(message="[状态]不能为空")
    @ApiModelProperty("状态")
    @TableField(value = "status")
    @Dict(dictCode = "produce_task_bill_sub_status")
    private Long status;

    @ApiModelProperty("计划开始日期")
    @TableField(value = "planStart")
    private Date planStart;

    @ApiModelProperty("计划结束日期")
    @TableField(value = "planEnd")
    private Date planEnd;

    @ApiModelProperty("实际开始日期")
    @TableField(value = "actualStart")
    private Date actualStart;

    @ApiModelProperty("实际结束日期")
    @TableField(value = "actualEnd")
    private Date actualEnd;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("生产批号")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "batchNum")
    private String batchNum;

    @NotBlank(message="[任务数量]不能为空")
    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("任务数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "qty")
    private BigDecimal qty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("派工数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "dispatchQty")
    private BigDecimal dispatchQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("报工数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "reportQty")
    private BigDecimal reportQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("报废数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "scrapQty")
    private BigDecimal scrapQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("返工数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "reworkQty")
    private BigDecimal reworkQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("待定数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "pendingQty")
    private BigDecimal pendingQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("拆分数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "splitQty")
    private BigDecimal splitQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("备注")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "remark")
    private String remark;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("生产类型(自制/委外)")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "routeType")
    @Dict(dictCode = "route_type")
    private Long routeType;

    @NotNull(message="[工作中心]不能为空")
    @ApiModelProperty("工作中心")
    @TableField(value = "workCenterId")
    private Long workCenterId;

    @ApiModelProperty("委外供应商")
    @TableField(value = "supplierId")
    private Long supplierId;

    @ApiModelProperty("生产资源Id")
    @TableField(value = "resourceId")
    @NotNull(message="[生产资源]不能为空")
    private Long resourceId;

    @ApiModelProperty("模具id")
    @TableField(value = "moldId")
    private Long moldId;

    @ApiModelProperty("模具穴数")
    @TableField(value = "moldQty")
    private Long moldQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("标准单小时数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "standardQty")
    private BigDecimal standardQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("标准班产数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "classProduceQty")
    private BigDecimal classProduceQty;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("标准工时")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "produceCycle")
    private BigDecimal produceCycle;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("加工单价")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "priceOne")
    private BigDecimal priceOne;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("描述")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "description")
    private String description;

    @ApiModelProperty("加工主单位")
    @TableField(value = "produceUnit")
    private Long produceUnit;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("加工主副换算率")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "produceRate")
    private BigDecimal produceRate;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("加工单价")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "producePriceOne")
    private BigDecimal producePriceOne;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("委外工价")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "producePriceOneOut")
    private BigDecimal producePriceOneOut;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("下道工序")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "nextSubNo")
    private String nextSubNo;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("工单备注附加文件")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "attachFiles")
    private String attachFiles;

    /**
     * 根据工艺工序复制出订单工序实例
     *
     * @param process 生产订单工艺工序实例
     * @return 订单工序实例
     */
    public static ProduceTaskBillSub getInstance(ProduceTaskBillRoutingProcess process) {
        ProduceTaskBillSub produceTaskBillSub = new ProduceTaskBillSub();
        BeanUtils.copyProperties(process, produceTaskBillSub, GenConstants.F_BASE_ENTITY);
        return produceTaskBillSub;
    }




}

